#pragma once

#include <iostream>
#include <vector>

#include <opencv2/opencv.hpp>

typedef unsigned int uint;
#define M_PI       3.14159265358979323846

class PathBuilder
{
	int GetRegions(cv::Mat &image, std::vector<uint> &labels);

	void PutLabel(cv::Mat &image, std::vector<uint> &labels, uint label, uint x, uint y);

	cv::Mat VizualizePath(cv::Mat &image, std::vector<uint> &labels, uint objNum);

	std::map<uint, std::pair<uint, uint>> GetCenter(std::vector<uint> & labels, uint objNum, cv::Size size);

	std::map<uint, uint> GetArea(std::vector<uint> & labels, uint objNum, cv::Size size);

	std::vector<std::pair<int, int>> FindNearestNeighbour(std::map<uint, std::pair<uint, uint>> centerCoord1,
		std::map<uint, std::pair<uint, uint>> centerCoord2, std::map<uint, uint> area1);

	void ChangeLabels(std::vector<std::pair<int, int>> & neighbours, std::map<uint, std::pair<uint, uint>> & centerCoord,
		std::map<uint, uint> & area);

	cv::Mat DrawPath(cv::Mat & image, std::vector<std::pair<int, int>> neighbors,
		std::map<uint, std::pair<uint, uint>> coord1, std::map<uint, std::pair<uint, uint>> coord2);

	void DrawLine(std::vector<std::pair<uint, uint>> & path, std::pair<uint, uint> coord1, std::pair<uint, uint> coord2);

	int objectAmount;

	std::map<uint, std::vector<std::pair<uint, uint>>> trajectory;

public:
	cv::Mat BuildPath(std::string path, uint amount);

	int GetSynteticDataForWFA();

	PathBuilder() : objectAmount(0) {}
};

